import java.util.Arrays;
import java.util.Scanner;

public class Main {

    //错误票据
    //先对数据进行输入
    //将数据放入创建的数组中
    //然后对数据排序
    //遍历数组，若后一位之比前一位大 1 ，则正确
    //若后一位比前一位大 2 ，则 int vanish = (array[i] + array[i + 1]) / 2
    //若后一位跟前一位的差值为 0 ，则 int repet = array[i]
    private static final int N = 100000;
    private static int[] a = new int[N];

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int cnt = 0;
        while(scanner.hasNextInt()){
            a[cnt++] = scanner.nextInt();
        }
        //输入完成，进行排序
        Arrays.sort(a,0,cnt);

        int x = 0;
        int y = 0;
        for (int i = 0; i < cnt; i++) {
            if(a[i] + 2 == a[i + 1]){
                x = a[i] + 1;
            }else if (a[i + 1] == a[i]){
                y = a[i];
            }
        }
        System.out.println(x + " " + y);
    }
}
